<!DOCTYPE html>
<!-- saved from url=(0037)http://mobileplus.yonyou.com/register -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta charset="utf-8">
  <title>申请内测</title>
  <link rel="stylesheet" href="./stylesheets/bootstrap.css" media="screen" title="no title" charset="utf-8">
  <link href="/stylesheets/builder.min.css" rel="stylesheet">
    <link href="/stylesheets/mystyle.css" rel="stylesheet">
    <link href="/stylesheets/style.css" rel="stylesheet">
    <script src="/javascripts/jquery.js" charset="utf-8"></script>
  <style media="screen">
  body {
      padding:0;
      margin: 0;
      background-image: url('/images/register.png');
      background-size: 100%;
  }
  input {
      padding-left: 10px;
  }
  </style>
  <script type="text/javascript">
      var flag = true;
      setInterval("refresh()",30000);
      function refresh() {
          var vcr=document.getElementById("validateCodeRegister");
          vcr.src = '/invitecode?t=' + new Date();
      }
      function changeLoginPage(){
          window.location.href='http://mobileplus.yonyou.com/register?type=login';
      }
      function register() {
          $('#message-name').prev().removeClass('error');
          $('#message-name').attr('style','visibility:hidden');
          $('#message-phone').prev().removeClass('error');
          $('#message-phone').attr('style','visibility:hidden');
          $('#message-email').prev().removeClass('error');
          $('#message-email').attr('style','visibility:hidden');
          $('#message-invitereason').prev().removeClass('error');
          $('#message-invitereason').attr('style','visibility:hidden');
          $('#message-company').prev().removeClass('error');
          $('#message-company').attr('style','visibility:hidden');
          $('#message-code').prev().removeClass('error');
          $('#message-code').attr('style','visibility:hidden');
        var username = $('input').eq(0).val();
        var phone = $('input').eq(1).val();
        var email = $('input').eq(2).val();
        var inviteCode = $('#invitereason').val();
          var company = $('input').eq(3).val();

          var validateCode = $('input').eq(4).val();
          if (!username) {
            console.log('用户名不能为空');
            $('#message-name').prev().addClass('error')
            $('#message-name').attr('style','visibility:visible');
            $('#message-name').html('用户名不能为空')
            return;
        }
          if (!phone||!/^1[3|4|5|7|8]\d{9}$/.test(phone)) {
            console.log('手机不正确');
              $('#message-phone').prev().addClass('error')
              $('#message-phone').attr('style','visibility:visible');
              $('#message-phone').html('手机不正确')
            return;
        }
          if (!email||!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email)) {
              $('#message-email').prev().addClass('error')
              $('#message-email').attr('style','visibility:visible');
              $('#message-email').html('邮箱不能为空')
              return;
          }
          if (!company) {
              $('#message-company').prev().addClass('error')
              $('#message-company').attr('style','visibility:visible');
              $('#message-company').html('单位名称不能为空')
              return;
          }
          if (!inviteCode) {
              $('#message-invitereason').prev().addClass('error')
              $('#message-invitereason').attr('style','visibility:visible');
              $('#message-invitereason').html('申请理由不能为空')
              return;
          }
          if (!validateCode) {
              $('#message-code').prev().addClass('error')
              $('#message-code').attr('style','visibility:visible');
              $('#message-code').html('验证码不能为空')
              return;
          }

              $.post(window.location.protocol+"//"+window.location.host+window.location.pathname+'?'+$("#collector").serialize(),function(data){
                  console.log(data);
                  if(data.code==-1){
                      if(data.error.type=='email'){
                          $('#message-email').prev().addClass('error')
                          $('#message-email').attr('style','visibility:visible');
                          $('#message-email').html(data.error.msg)
                      }else {
                          alert(data.error.msg);
                      }

                  }else{
                      console.log(data.success.msg);
                      alert(data.success.msg+"");
                      history.go(0);
                  }
              });
          }

//      function checkuser(e){
//          var email =e.value;
//          if (!email||!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email)) {
//              $('#message-email').prev().addClass('error')
//              $('#message-email').attr('style','visibility:visible');
//              $('#message-email').html('邮箱不能为空')
//              return;
//          }else{
//              var url= "http://innovation.yonyou.com:7000/user/alpha/isUniqueEmail/"+ email
//              $.get(url,function(data){
//                  if(!data.result){
//                      flag=false
//                      $('#message-name').prev().addClass('error')
//                      $('#message-name').attr('style','visibility:visible');
//                      $('#message-name').html('邮箱"'+email+'"已经注册过账号,可以直接登陆,如忘记密码,可通过找回密码功能找回');
//                  }else{
//                      flag=true;
//                  }
//
//              });
//          }
//      }
  </script>
</head>
<body>
  <div class="register">
    <div class="left">
      <form id='collector' class="" method="POST">
          <div class="title">申请内测</div>
          <div class="context">
              <div>
                  <label>姓名</label>
                  <div class="item icon-ab-username">
                      <input type="text" name="username"  placeholder="请输入姓名">
                  </div>
                  <div class="message" id="message-name">姓名不能为空</div>
              </div>
              <div>
                  <label>手机</label>
                  <div class="item icon-ab-phoneNemble">
                      <input type="number" name="phone" placeholder="请输入手机">
                  </div>
                  <div class="message" id="message-phone">手机不能为空</div>
              </div>
              <div>
                  <label>邮箱</label>
                  <div class="item icon-ab-mail">
                      <input type="email" name="email" placeholder="请输入邮箱">
                  </div>
                  <div class="message" id="message-email">邮箱不能为空</div>
              </div>
              <div>
                  <label>单位名称</label>
                  <div class="item icon-ab-head-home">
                      <input type="text" name="company" placeholder="请输入单位名称">
                  </div>
                  <div class="message" id="message-company">单位名称不能为空</div>
              </div>
              <div>
                  <label>申请说明</label>
                  <div class="item">
                      <textarea id="invitereason" type="text"  name="invitereason" class="inviteCode" style="width:280px;height: 100px;vertical-align:middle;border-radius: 5px;outline: none;" placeholder="请输入内测案例描述"></textarea>
                  </div>
                  <div class="message" id="message-invitereason">内测案例描述不能为空</div>
              </div>
              <div style="margin-right: 4px;">
                  <label>验证码</label>
                  <input type="text" name="validateCode" class="validateCode" placeholder="请输入验证码">
                  <!-- <img width="125px;height:36px;" src="/validateCode" id='validateCodeRegister' onclick="refresh(this)" /> -->
                  <img width="125px;height:36px;" src="/invitecode" id="validateCodeRegister" onclick="refresh(this)">
                  <div class="message" id="message-code">验证码不能为空</div>
              </div>
              <div>
                  <!-- <button name='register' id="registerId">立即注册</button> -->
                  <input type="button" value="立即申请" onclick="register()" class="type-button">
              </div>
          </div>
      </form>
  </div>
    <div class="sepalate"></div>
    <div class="right">
      <div class="login">
          <div class="title">已有账号 ?</div>
          <button id="loginNowId" onclick="changeLoginPage()">立即登录</button>
      </div>
  </div>
  </div>
  </body>
</html>